/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "Reservation")
@NamedQueries({
    @NamedQuery(name = "Reservation.findAll", query = "SELECT r FROM Reservation r"),
    @NamedQuery(name = "Reservation.findByDateReservation", query = "SELECT r FROM Reservation r WHERE r.dateReservation = :dateReservation"),
    @NamedQuery(name = "Reservation.findByIdReservation", query = "SELECT r FROM Reservation r WHERE r.idReservation = :idReservation")})
public class Reservation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateReservation", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateReservation;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idReservation", nullable = false)
    private Integer idReservation;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reservation")
    private List<ExemplaireReservation> exemplaireReservationList;
    @JoinColumn(name = "ItemRef", referencedColumnName = "ItemRef", nullable = false)
    @ManyToOne(optional = false)
    private Item itemRef;
    @JoinColumn(name = "NoCarte", referencedColumnName = "NoCarte", nullable = false)
    @ManyToOne(optional = false)
    private Adherent noCarte;

    public Reservation() {
    }

    public Reservation(Integer idReservation) {
        this.idReservation = idReservation;
    }

    public Reservation(Integer idReservation, Date dateReservation) {
        this.idReservation = idReservation;
        this.dateReservation = dateReservation;
    }

    public Date getDateReservation() {
        return dateReservation;
    }

    public void setDateReservation(Date dateReservation) {
        this.dateReservation = dateReservation;
    }

    public Integer getIdReservation() {
        return idReservation;
    }

    public void setIdReservation(Integer idReservation) {
        this.idReservation = idReservation;
    }

    public List<ExemplaireReservation> getExemplaireReservationList() {
        return exemplaireReservationList;
    }

    public void setExemplaireReservationList(List<ExemplaireReservation> exemplaireReservationList) {
        this.exemplaireReservationList = exemplaireReservationList;
    }

    public Item getItemRef() {
        return itemRef;
    }

    public void setItemRef(Item itemRef) {
        this.itemRef = itemRef;
    }

    public Adherent getNoCarte() {
        return noCarte;
    }

    public void setNoCarte(Adherent noCarte) {
        this.noCarte = noCarte;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idReservation != null ? idReservation.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reservation)) {
            return false;
        }
        Reservation other = (Reservation) object;
        if ((this.idReservation == null && other.idReservation != null) || (this.idReservation != null && !this.idReservation.equals(other.idReservation))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.Reservation[ idReservation=" + idReservation + " ]";
    }
    
}
